﻿<?php
include 'config.php';
include 'opendb.php';

if(isset($_GET['q']))
{
$q=$_GET['q'];   $qw=$_GET['qw'];
//if (!$q) return;
//if (strlen($q)<2) return;  //从第二个字母开始感应

switch($qw){
case "lat":    //拉丁学名自动提示效果
 $where="ScientificName";
 $query ="select ScientificName from ".$auto_list." where ScientificName like '".$q."%' and length(LSID)>2 limit 10" ;
 break;
case "ch":     //中文名自动提示效果
 $where="CommonName";
 $query ="select CommonName from ".$auto_list." where CommonName like '%".$q."%' group by CommonName  limit 10" ;
 break;
case "gen":    //属名自动提示效果
 $where="Genus";
 $query ="select Genus from ".$auto_list." where Genus like '".$q."%' group by Genus  limit 10" ;
 break;
case "fam":    //科名自动提示效果
 $where="Family";
 $query ="select Family from ".$auto_list." where Family like '".$q."%' group by Family  limit 10" ;
 break; 
}

mysql_query("set names 'utf8'");
$result = mysql_query($query);
if($result){
   while($rows = mysql_fetch_assoc($result))
   echo   $rows[$where]."\n";       
  }
  } 
 else ;
 ?>